package com.incar.chuxing.utils;

import static com.incar.chuxing.utils.StateType.State.PAGER_NEAR;
import static com.incar.chuxing.utils.StateType.State.PAGER_ONE_AND_NEAR;
import static com.incar.chuxing.utils.StateType.State.SHOW_PAGER;

/**
 * Created by Michael on 12/13.
 */

public class StateType {


    private static State curState = State.DEFAULT;
    public static LoadMarkerState loadState = LoadMarkerState.LOAD_DONE;

    /**
     * 主页面显示状态标记
     */
    public enum State {
        DEFAULT,//初始状态
        CAR_FIND, //寻车状态
        PAGER_NEAR,//点选车，附近二十辆
        PAGER_ONE_AND_NEAR,//点单个车辆，附带附近二十辆

        SHOW_PAGER, //PAGER_ONE_AND_NEAR,PAGER_NEAR均属于CAR_PAGER状态
        SHOW_CITY
    }


    public static State getCurState() {
        return curState;
    }

    public static void setCurState(State curState) {
        StateType.curState = curState;
        RxBus.getInstance().post(curState);
    }

    /**
     * 判断当前状态是否属于要比对的状态
     *
     * @param requestState 要比对的状态
     * @return
     */
    public static boolean isEqualsCurStates(State requestState) {
        if (curState == requestState) {
            return true;
        } else if (requestState == SHOW_PAGER) {
            //CAR_PAGER_PARK,CAR_PAGER_NEAR_TWENTY均属于CAR_PAGER状态
            if (curState == PAGER_ONE_AND_NEAR || curState == PAGER_NEAR) {
                return true;
            }
        }
        return false;
    }


    /**
     * 主页面显示状态标记
     */
    public enum LoadMarkerState {
        LOADING,//车辆加载中
        LOAD_FIRST_DONE,//第一页加载完毕
        LOAD_DONE //车辆加载完毕
    }

}
